package zdc.ui {
import flash.display.MovieClip;

/**
 *
 * @author Simple Slime
 */
public class MenuGroupUtil {
    /**
     * 菜单组的gotoAndStop
     * @param    arr
     * @param    target
     * @param    targetFrame
     * @param    otherFrame
     */
    public static function gotoAndStop(arr:Array, target:MovieClip, targetFrame:int = 2, otherFrame:int = 1):void {
        var len:int = arr.length;
        for (var i:int = 0; i < len; i++) {
            var m:MovieClip = arr[i];
            m.gotoAndStop(m == target ? targetFrame : otherFrame);
        }
    }

    /**
     * 菜单组的gotoAndPlay
     * @param    arr
     * @param    target
     * @param    targetFrame
     * @param    otherFrame
     */
    public static function gotoAndPlay(arr:Array, target:MovieClip, targetFrame:int = 2, otherFrame:int = 1):void {
        var len:int = arr.length;
        for (var i:int = 0; i < len; i++) {
            var m:MovieClip = arr[i];
            if (m == target) {
                m.gotoAndPlay(targetFrame);
            }
            else {
                m.gotoAndStop(otherFrame);
            }
        }
    }

    public static function allGotoAndStop(arr:Array, targetFrame:int = 1):void {
        var len:int = arr.length;
        for (var i:int = 0; i < len; i++) {
            var m:MovieClip = arr[i];
            m.gotoAndStop(targetFrame);
        }
    }

    public static function allGotoAndPlay(arr:Array, targetFrame:int = 1):void {
        var len:int = arr.length;
        for (var i:int = 0; i < len; i++) {
            var m:MovieClip = arr[i];
            m.gotoAndPlay(targetFrame);
        }
    }
}
}